package com.jcl.recruit.org.mapper;


import com.jcl.recruit.org.model.Department;
import com.jcl.core.utils.StringUtils;

import static org.apache.ibatis.jdbc.SqlBuilder.*;

/**
 * @ClassName DepartmentProdiver

 * @Author yyliu
 * @Date 2018/9/12 18:40
 * @Version 1.0
 **/
public class DepartmentProdiver {

    public String insertSelective(Department department){

        BEGIN();
        INSERT_INTO("department");

        if(StringUtils.hasLength(department.getFullname())){
            VALUES("fullname", "#{fullname, jdbcType=VARCHAR}");
        }
        if(StringUtils.hasLength(department.getShortname())){
            VALUES("shortname", "#{shortname, jdbcType=VARCHAR}");
        }
        if(StringUtils.hasLength(department.getCode())){
            VALUES("code", "#{code, jdbcType=VARCHAR}");
        }

        if(null != department.getShoworder()){
            VALUES("showorder", "#{showorder, jdbcType=INTEGER}");
        }
        if(null != department.getSubcompanyId()){
            VALUES("subcompany_id", "#{subcompanyId, jdbcType=INTEGER}");
        }

        if(StringUtils.hasLength(department.getCorpCode())){
            VALUES("corp_code", "#{corpCode, jdbcType=VARCHAR}");
        }
        if(null != department.getSuperId()){
            VALUES("super_id", "#{superId, jdbcType=INTEGER}");
        }

        return SQL();
    }
}
